package com.xlh.thread;

import android.content.Context;
import android.os.Message;


import android.os.Handler;
import com.xlh.outside.MainActivity;

public class MessageBagerTask implements Runnable{



	public Context context = null;
	//外部
	private Handler handler;
	private String type;
	private String data;
	private int messageNumber;

	public int getMessageNumber() {
		return messageNumber;
	}

	public MessageBagerTask setMessageNumber(int messageNumber) {
		this.messageNumber = messageNumber;
		return this;
	}

	public String getData() {
		return data;
	}

	public MessageBagerTask setData(String data) {
		this.data = data;
		return this;
	}

	public String getType() {
		return type;
	}

	public MessageBagerTask setType(String type) {
		this.type = type;
		return this;
	}

	public Context getContext() {
		return context;
	}




	public MessageBagerTask setContext(Context context) {

		this.context = context;
		return this;
	}

	public Handler getHandler() {
		return handler;
	}

	public MessageBagerTask setHandler(Handler handler) {
		this.handler = handler;
		return this;
	}



	@Override
	public void run() {

			Message msg = Message.obtain();
			msg.what = getMessageNumber();
			msg.obj = getData();
			if(getHandler()==null){//没有定义外部
			((MainActivity)context).getHandler().sendMessage(msg);
		}else{
			getHandler().sendMessage(msg);
		}



	}



}
